package week10;

import java.util.Scanner;

class Resource{
	public void open(String str) throws Exception{
		if(str.equals("fail success")) {
			System.out.println( new Exception());
			System.out.println("resource release success");
		}
		else if(str.equals("success success")) {
			System.out.println("resource open success");
			System.out.println("resource release success");
		}
		else if(str.equals("success fail")) {
			System.out.println("resource open success");
			throw new Exception();
		}
		else if(str.equals("fail fail")) {
			System.out.println(new Exception());
			System.out.println(new RuntimeException());
		}
	}
	public void close() throws RuntimeException{
		
	}
}
public class PTA6_2 {

	public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    Resource resource = null;
	    try{
	        resource = new Resource();
	        resource.open(sc.nextLine());
	        System.out.println("resource open success");
	    }catch(Exception e) {
	    	System.out.println(e);
	    }
	    finally {
	    	try{
	    		resource.close();
	    		System.out.println("resource release success");
	    	}catch(Exception e) {
	    		System.out.println(e);
	    	}
	    }
	    sc.close();
	    }
	   

}
